<?php

/*
 * Created on Feb 22, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
?>
<?php
class Mylanguage {

	/**
	 *
	 *
	 */
	function Mychange() {
		$CI =& get_instance();
		if(!isset($_SESSION[LANGUAGE_CURRENT])){
			$_SESSION[LANGUAGE_CURRENT] = $CI->config->item("lang_suffix_default");
		}
		else{
			$lang_current = $_SESSION[LANGUAGE_CURRENT];
			if(empty($lang_current) || !preg_match("/^[a-z]{2}$/", $lang_current)){
				$_SESSION[LANGUAGE_CURRENT] = $CI->config->item("lang_suffix_default");
			}

		}
		$segments = $CI->uri->segments;

		if (is_array($segments) and !empty ($segments[1]) and (preg_match("/^[a-z]{2}$/", $segments[1]))) {
			$_SESSION[LANGUAGE_CURRENT] = $segments[1];
		}
		$CI->lang->load('base', $_SESSION[LANGUAGE_CURRENT]);
	}
}
?>